<template>
	<view class="equip-list">
		<view :id="'equip' + equip.id" class="equip-li" v-for="equip in list" :key="equip.id">
			<view class="flex-item" @click="onItemClick(equip)" :class="{hide:equip.__hide}">
				<view style="position: absolute;right:20rpx;margin-top:10rpx">
					<view>
						<text v-if="equip.do_status==2" class="cu-tag round bg-gray sm">已完成</text>
						<text v-else-if="equip.do_status==1"  class="cu-tag round bg-green sm">进行中</text>
						<text v-else class="cu-tag round bg-orange sm">待处理</text>
					</view>
				</view>
				<view style="position: absolute;right:20rpx;margin-top:66rpx">
					<text class="cu-tag round  sm line-blue">{{equip.maintain_type}}</text>
				</view>
				<view>
					<uni-icons type="location-filled" color="#f1b41a"></uni-icons>
					<text style="    font-weight: bold;">{{ equip.eqp_name }}{{equip.eqp_id}}</text>
				</view>
				<view>
					<text style="color:#888;padding:0 40rpx">设备类型</text>
					<text>{{ equip.eqp_type_name }}</text>
				</view>
				<view>
					<text style="color:#888;padding:0 40rpx">检查模板</text>
					<text>{{ equip.template_name }}</text>
				</view>
				<view>
					<text style="color:#888;padding:0 40rpx">计划时间</text>
					<text>{{ equip.start_dt }}~{{equip.end_dt}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	props: {
		list: {
			type: Array,
			default() {
				return [];
			}
		},
		confirmCode:String
	},methods:{
		onItemClick(equip){
			
			var paramList = []
			paramList.push(`id=${equip.id}`)
			paramList.push(`confirm_code=${equip.confirm_code}`)
			paramList.push(`do_result=${equip.do_result}`)
			paramList.push(`do_status=${equip.do_status}`)
			paramList.push(`task_code=${equip.task_code}`)
			paramList.push(`eqp_id=${equip.eqp_id}`)
			paramList.push(`start_dt=${equip.start_dt}`)
			paramList.push(`confirmCode=${this.confirmCode}`)
			
			uni.navigateTo({
				url:`/pages/equip/detail?`+ (paramList.join("&")),
				success:(res)=> {
					// res.eventChannel.emit('acceptDataFromOpenerPage',{data:equip})
				}
			})
		}
		// ,onEquipTaskDetailSaveAfter(taskInfo){
		// 	console.log('接收到任务保存成功',taskInfo)
		// }
	
	},onLoad(){
		// uni.$on('onEquipTaskDetailSave', this.onEquipTaskDetailSaveAfter)
	},
	onUnload() {
	    //uni.$off('onEquipTaskDetailSave', this.onEquipTaskDetailSaveAfter)
	}
};
</script>

<style lang="scss">
.equip-list {
	// background-color: #eee;
	background-color: #fff;
	.equip-li {
		display: flex;
		align-items: center;
		padding: 20upx;
		border-bottom: 1upx solid #eee;

		.equip-img {
			width: 160upx;
			height: 160upx;
			margin-right: 20rpx;
		}

		.flex-item {
			flex: 1;

			.equip-name {
				font-size: 26upx;
				line-height: 40upx;
				height: 80upx;
				margin-bottom: 20upx;
				overflow: hidden;
			}
			.equip-price {
				font-size: 26upx;
				color: red;
			}
			.equip-sold {
				font-size: 24upx;
				margin-left: 16upx;
				color: gray;
			}
		}
	}
}
</style>
